package org.flexlancer.databases
{
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	public class QuantityUnit extends EventDispatcher
	{
		public static var LastInsertedID:Number = -1;
		private static const TABLE:String = "quantityunit";
		public function QuantityUnit(target:IEventDispatcher=null)
		{
			super(target);
		}
		
		public static function Add(parmUnitName:String):void{
			try{
				var insertObj:Object = new Object();
				insertObj.qname = " '" + parmUnitName + "' ";
				DatabaseManager.Manager.Insert(TABLE,insertObj);
				LastInsertedID = DatabaseManager.Manager.LastInsertRowID;
			}catch(err:Error){
				throw err;
			}
		}
		public static function Delete(parmUnitID:String):void{
			try{
				DatabaseManager.Manager.Delete(TABLE,"qunitid = "+parmUnitID);
			}catch(err:Error){
				throw err;
			}
		} 
		public static function List():Array{
			try{
				return DatabaseManager.Manager.Select(TABLE,null,"","qname");
			}catch(err:Error){
				throw err;
			}
			return null;
		}
	}
}